package com.backend.thread.reentrantLock

import kotlin.concurrent.thread

object Application {
    private val b = SimpleMessageBuffer()
    @JvmStatic
    fun main(args: Array<String>) {
        val size = 10
        thread {
            var i = 0
            while (i < size) {
                try {
                    b.put(i++)
                } catch (e: InterruptedException) {
                    e.printStackTrace()
                }
            }
        }

        thread {
            var i = 0
            while (i++ < size) {
                try {
                    b.take()
                } catch (e: InterruptedException) {
                    e.printStackTrace()
                }
            }
        }
    }
}